package com.fengke.dao.model;

import java.util.Date;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.fengke.dao.model.MemberModel.Gender;

public class OrderModel extends BaseEntity {
	private static final long serialVersionUID = -6292203145387441000L;
	/** 到期时间 */
	private Date expire;
	/** 锁定到期时间 */
	private Date lockExpire;

	/**
	 * 订单状态
	 */
	public enum OrderStatus {
		/** 未确认 */
		unconfirmed(0),
		/** 已确认 */
		confirmed(1),
		/** 已完成 */
		completed(2),
		/** 已取消 */
		cancelled(3);
		
		private int status;

		OrderStatus(int status) {
			this.status = status;
		}

		public int getStatus() {
			return this.status;
		}
	}

	/**
	 * 支付状态
	 */
	public enum PaymentStatus {
		/** 未支付 */
		unpaid(0),
		/** 部分支付 */
		partialPayment(1),
		/** 已支付 */
		paid(2),
		/** 部分退款 */
		partialRefunds(3),
		/** 已退款 */
		refunded(4);
		
		private int status;

		PaymentStatus(int status) {
			this.status = status;
		}

		public int getStatus() {
			return this.status;
		}
	}

	/**
	 * 发票内容
	 */
	public enum InvoiceContent {
		/** 不开发票 */
		no(0),
		/** 明细 */
		detail(1),
		/** 办公用品 */
		office(2),
		/** 电脑配件 */
		computer(3),
		/** 耗材 */
		consume(4);
		
		private int content;

		InvoiceContent(int content) {
			this.content = content;
		}

		public int getContent() {
			return this.content;
		}
	}

	/** 订单状态 */
	private OrderStatus orderStatus;
	private Integer morderStatus;
	/** 支付状态 */
	private PaymentStatus paymentStatus;
	private Integer mpaymentStatus;
	/** 支付方式名称 */
	private String paymentMethodName;
	/** 电话 */
	private String phone;
	/** 订单编号 */
	private String sn;
	/** 会员 */
	private MemberModel member;
	/** 操作员 */
	private AdminModel operator;
	/** 商户id */
	private Long adminId;
	/** 是否有发票 */
	private Boolean isInvoice;
	/** 发票抬头 */
	private String invoiceTitle;
	private InvoiceContent invoiceContent = InvoiceContent.no;
	private Integer minvoiceContent;
	/** 成人数 */
	private Long adultNum;
	/** 儿童数 */
	private Long childrenNum;
	/** 邮箱 */
	private String email;
	private Gender gender;
	private Integer mgender;
	private Date goDate;
	private Boolean isShareHouse;
	private String productName;
	/**
	 * 附言
	 */
	private String memo;
	/**
	 * 该订单的购买者是否同行人可见
	 */
	private Boolean isAssociateShow;
	/** 订单是否有效 */
	private Boolean isEffective;
	/** 机主姓名 */
    private String phoneName;
    /** 地址 */
    private String address;
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	public Long getTotalNum(){
    	if(adultNum!=null&&childrenNum!=null){
    		return adultNum+childrenNum;
    	}
    	return 0l;
    }
	public Date getExpire() {
		return expire;
	}

	public void setExpire(Date expire) {
		this.expire = expire;
	}

	public Date getLockExpire() {
		return lockExpire;
	}

	public void setLockExpire(Date lockExpire) {
		this.lockExpire = lockExpire;
	}

	public OrderStatus getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(OrderStatus orderStatus) {
		this.orderStatus = orderStatus;
	}

	public PaymentStatus getPaymentStatus() {
		return paymentStatus;
	}

	public void setPaymentStatus(PaymentStatus paymentStatus) {
		this.paymentStatus = paymentStatus;
	}

	public String getPaymentMethodName() {
		return paymentMethodName;
	}

	public void setPaymentMethodName(String paymentMethodName) {
		this.paymentMethodName = paymentMethodName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getSn() {
		return sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	public MemberModel getMember() {
		return member;
	}

	public void setMember(MemberModel member) {
		this.member = member;
	}

	public AdminModel getOperator() {
		return operator;
	}

	public void setOperator(AdminModel operator) {
		this.operator = operator;
	}

	public Long getAdminId() {
		return adminId;
	}

	public void setAdminId(Long adminId) {
		this.adminId = adminId;
	}

	public String getInvoiceTitle() {
		return invoiceTitle;
	}

	public void setInvoiceTitle(String invoiceTitle) {
		this.invoiceTitle = invoiceTitle;
	}

	public InvoiceContent getInvoiceContent() {
		return invoiceContent;
	}

	public void setInvoiceContent(InvoiceContent invoiceContent) {
		this.invoiceContent = invoiceContent;
	}

	public Long getAdultNum() {
		return adultNum;
	}

	public void setAdultNum(Long adultNum) {
		this.adultNum = adultNum;
	}

	public Long getChildrenNum() {
		return childrenNum;
	}

	public void setChildrenNum(Long childrenNum) {
		this.childrenNum = childrenNum;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public Date getGoDate() {
		return goDate;
	}

	public void setGoDate(Date goDate) {
		this.goDate = goDate;
	}

	public Boolean getIsShareHouse() {
		return isShareHouse;
	}

	public void setIsShareHouse(Boolean isShareHouse) {
		this.isShareHouse = isShareHouse;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public Boolean getIsAssociateShow() {
		return isAssociateShow;
	}

	public void setIsAssociateShow(Boolean isAssociateShow) {
		this.isAssociateShow = isAssociateShow;
	}

	public Boolean getIsEffective() {
		return isEffective;
	}

	public void setIsEffective(Boolean isEffective) {
		this.isEffective = isEffective;
	}

	public Integer getMorderStatus() {
		if(this.orderStatus == null) {
			return null;
		}
		this.morderStatus = this.orderStatus.getStatus();
		return morderStatus;
	}

	public void setMorderStatus(Integer morderStatus) {
		if(morderStatus == null) {
			return;
		}
		if(morderStatus == OrderStatus.unconfirmed.getStatus()) {
			this.orderStatus = OrderStatus.unconfirmed;
		} else if(morderStatus == OrderStatus.confirmed.getStatus()) {
			this.orderStatus = OrderStatus.confirmed;
		} else if(morderStatus == OrderStatus.completed.getStatus()) {
			this.orderStatus = OrderStatus.completed;
		} else if(morderStatus == OrderStatus.cancelled.getStatus()) {
			this.orderStatus = OrderStatus.cancelled;
		}
		this.morderStatus = this.orderStatus.getStatus();
	}

	public Integer getMpaymentStatus() {
		if(this.paymentStatus == null) {
			return null;
		}
		this.mpaymentStatus = this.paymentStatus.getStatus();
		return mpaymentStatus;
	}

	public void setMpaymentStatus(Integer mpaymentStatus) {
		if(mpaymentStatus == null) {
			return;
		}
		if(mpaymentStatus == PaymentStatus.unpaid.getStatus()) {
			this.paymentStatus = PaymentStatus.unpaid;
		} else if(mpaymentStatus == PaymentStatus.partialPayment.getStatus()) {
			this.paymentStatus = PaymentStatus.partialPayment;
		} else if(mpaymentStatus == PaymentStatus.paid.getStatus()) {
			this.paymentStatus = PaymentStatus.paid;
		} else if(mpaymentStatus == PaymentStatus.partialRefunds.getStatus()) {
			this.paymentStatus = PaymentStatus.partialRefunds;
		} else if(mpaymentStatus == PaymentStatus.refunded.getStatus()) {
			this.paymentStatus = PaymentStatus.refunded;
		}
		this.mpaymentStatus = this.paymentStatus.getStatus();
	}

	public Integer getMinvoiceContent() {
		if(this.invoiceContent == null) {
			return null;
		}
		this.minvoiceContent = this.invoiceContent.getContent();
		return minvoiceContent;
	}

	public void setMinvoiceContent(Integer minvoiceContent) {
		if(minvoiceContent == null) {
			return;
		}
		if(minvoiceContent == InvoiceContent.no.getContent()) {
			this.invoiceContent = InvoiceContent.no;
		} else if(minvoiceContent == InvoiceContent.detail.getContent()) {
			this.invoiceContent = InvoiceContent.detail;
		} else if(minvoiceContent == InvoiceContent.office.getContent()) {
			this.invoiceContent = InvoiceContent.office;
		} else if(minvoiceContent == InvoiceContent.computer.getContent()) {
			this.invoiceContent = InvoiceContent.computer;
		} else if(minvoiceContent == InvoiceContent.consume.getContent()) {
			this.invoiceContent = InvoiceContent.consume;
		}
		this.minvoiceContent = this.invoiceContent.getContent();
	}

	public Integer getMgender() {
		this.mgender = this.gender.getGender();
		return mgender;
	}

	public void setMgender(Integer mgender) {
		if(mgender == null) {
			return;
		}
		if(mgender == Gender.male.getGender()) {
			this.gender = Gender.male;
		} else if(mgender == Gender.female.getGender()) {
			this.gender = Gender.female;
		}
		this.mgender = this.gender.getGender();
	}

	public Boolean getIsInvoice() {
		return isInvoice;
	}

	public void setIsInvoice(Boolean isInvoice) {
		this.isInvoice = isInvoice;
	}
	public String getPhoneName() {
		return phoneName;
	}
	public void setPhoneName(String phoneName) {
		this.phoneName = phoneName;
	}
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
}
